package com.sskj.phoenixcoin.presenter;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.phoenixcoin.activity.AppTransferActivity;
import com.sskj.phoenixcoin.bean.AppBanlance;
import com.sskj.phoenixcoin.bean.AppUser;
import com.sskj.phoenixcoin.http.HttpConfig;


public class AppTransferActivityPresenter extends BasePresenter<AppTransferActivity> {
    // 根据账号查询名称
    public void transferSearch(String tel) {
        OkGo.<HttpData<AppUser>>post(HttpConfig.BASE_URL + HttpConfig.TRANSFER_SEARCH)
                .params("systemType", "ANDROID")
                .params("tel", tel)
                .tag(this)
                .execute(new JsonCallBack<HttpData<AppUser>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<AppUser>> response) {
                        HttpData body = response.body();
                        ToastUtil.showShort(body.getMsg());
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.updateName((AppUser) body.getData());
                        }
                    }
                });
    }

    // 转账
    public void transfer(String selfStockUserId, String otherTel, String coinNum, String phoenixTradePwd, String coinType, String chargeType) {
        OkGo.<HttpData<AppUser>>post(HttpConfig.BASE_URL + HttpConfig.TRANSFER)
                .params("systemType", "ANDROID")
                .params("selfStockUserId", selfStockUserId)
                .params("otherTel", otherTel)
                .params("phoenixTradePwd", MD5Util.getMd5Value(phoenixTradePwd))
                .params("coinType", coinType)
                .params("coinNum", coinNum)
                .params("chargeType", chargeType)
                .tag(this)
                .execute(new JsonCallBack<HttpData<AppUser>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<AppUser>> response) {
                        HttpData body = response.body();
                        ToastUtil.showShort(body.getMsg());
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.successUi();
                        }
                    }
                });
    }
}
